package com.gjintel.auction.business.dao.daoImpl;

import com.gjintel.auction.business.dao.IAuctionEntryDao;
import com.gjintel.auction.business.model.RegAudit;
import com.gjintel.sdk.base.dao.HibernateGenericDAO;
import com.gjintel.sdk.base.dao.Page;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/11/23.
 */
@Repository
public class AuctionEntryDaoImpl extends HibernateGenericDAO implements IAuctionEntryDao {

    @Override
    public boolean getEntryAble(String auctionId, String userId) {
        List<Object> params = new ArrayList<Object>();
        String hql = "from RegAudit ra where ra.auctionId like ? and ra.regId = ? and ra.status = 2";//
        params.add(auctionId);
        params.add(userId);
        Page page = new Page();
        page.setPageNo(1);
        page.setPageSize(1);
        List<RegAudit> regAuditList = this.findAsPage(hql, page, params.toArray());
        if (regAuditList == null || regAuditList.size() <= 0) {
            return false;
        }
        return true;
    }
}
